﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CourseUtils;

namespace NumberReverse
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int value = IOHelpers.ReadIntFromConsole("enter value pls", 0, 99999);
            ReverseAndPrintNumber(value);
            Console.ReadKey();
        }

        public static int findingNumLength(int value)
        {
            string str = value.ToString();
            int length = str.Length;
            return length;
        }

        public static int IntPow(int x, int pow)
        {
            int result = 1;
            for (int i = 0; i < pow; i++)
            {
                result *= x;
            }
                return result;        
        }

        public static int ReverseAndPrintNumber(int value)
        {
            int fnl = findingNumLength(value) - 1;
            int ReverseValue = 0;
            int intVal = value;
            for (int i = 0; i < findingNumLength(value) - 1; i++)
            {                
                int RValue = intVal % 10;
                RValue = RValue * IntPow(10, fnl);
                ReverseValue += RValue;
                intVal = intVal / 10;
                fnl--;
            }
            ReverseValue = ReverseValue + intVal;
            Console.Write("Reverse value: {0}", ReverseValue);
            return ReverseValue;
        }
    }
}
